<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__CSS__/pintuer.css?v={$src_version}">
<link rel="stylesheet" href="__CSS__/admin.css?v={$src_version}">
<link rel="stylesheet" href="__CSS__/responsive.css?v={$src_version}">
<script src="__JS__/jquery-3.2.1.min.js?v={$src_version}"></script>
<script src="__JS__/pintuer.js?v={$src_version}"></script>
<script src="__JS__/jquery.nicescroll.js"></script>
<script src="__PUBLIC__/layer.js?v={$src_version}"></script>
<script src="__JS__/ming.js?v={$src_version}"></script>
<script src="__JS__/ifram_scroll.js?v={$src_version}"></script>
<script src="__JS__/responsive.js?v={$src_version}"></script>
 
<body>
<div class="panel admin-panel">
<div class="padding">   
  <form method="post" action="{:U('User/index')}?act=search" class="search-form"  id="frm1">
      <ul class="search">
       <li>
          <input type="text" value="{$con.keywords}" placeholder="请输入姓名或手机号" name="keywords" class="input search-input" />
         </li>
        <li>   
         <a href="javascript:void(0)" class="button border-main icon-search" id="dosearch" style="padding: 10px 15px;"> 搜索</a>
        </li>
      </ul>
      
    </form>  
      
    </div>
    
		<a type="button" class="button border-yellow" onclick="window.location.href='{:U('User/add')}'" style="padding:3px 5px; ">
			<span class="icon-plus-square-o"></span>添加员工</a> 
    <table class="table table-hover text-center">
      <tr>
         <th></th>
        <th style="text-align:left;">员工姓名</th> 
        <th>手机号码</th>
        <th>头像</th>
        <th>员工积分</th>
        <th>操作</th>
      </tr>
      <volist name="user" id="v">
        <tr>
          <td >
          <input type="checkbox" name="id[]" value="{$v.uid}" />
        </td>
          <td style="text-align:left;">{$v.realname}</td>
          <td>{$v.mobile}</td>
            <td style=" height:50px;"><if condition="$v['headimgurl'] neq ''"><img src="/{$v.headimgurl}"  style="display:block; margin:0 auto; height:100%; width:auto; overflow:hidden;" /></if></td> 
          <td>{$v.upoint}</td>
          <td> 
          <div class="button-group"> 
          <a class="button border-main" href="{:U('User/add')}?id={$v.uid}"><span class="icon-edit"></span> 修改</a> 
          <a class="button border-main" href="{:U('User/point')}?id={$v.uid}"><span class="icon-edit"></span> 一般积分操作</a> 
          <a class="button border-main" href="{:U('User/type')}?id={$v.uid}"><span class="icon-edit"></span> 部门积分操作</a> 
          <a class="button border-main" href="{:U('User/full')}?id={$v.uid}"><span class="icon-edit">积分详情</span></a>
          <a class="button border-main" href="javascript:void(0)" onclick="return clear_point({$v.uid})"><span class="icon-edit"></span> 积分清零</a> 
          <a class="button border-red" href="javascript:void(0)" onclick="return del({$v.uid})"><span class="icon-trash-o"></span> 删除</a> 
          </div>
          </td>
        </tr>
        </volist>
  
 <?php if(intval(count($user))>0){ ?>
   <tr  class="no-hover">
        <td style="text-align:left; padding:19px 0;padding-left:20px;">
        <input type="checkbox" id="checkall"/>
          全选 </td>
        <td colspan="80" style="text-align:left;padding-left:20px;"><a c href="javascript:void(0)" class="button border-red delete icon-trash-o" style="padding:5px 15px;"> 删除</a> 
          </td>
      </tr>
       <tr  class="no-hover" style="border-bottom:none"> <td style="border-bottom:none" colspan="80"><div class="pagelist"><?php echo $page; ?></div></td></tr>  
      <?php }else{ ?>  
         <tr  class="no-hover"><td style="border-bottom:none" colspan="80"><div class="pagelist"><?php  echo '暂无记录'; ?></div></td></tr> 
      <?php } ?>  
    </table>
  </div>

<script type="text/javascript">

$(function(){
	 //搜索
	$('#dosearch').click(function(){$('#frm1').submit();} );  
	//批量删除
	$('.delete').click(function(){
			DelSelect();

	});
});

//单个删除
function del(id){
	layer.confirm('您确定要删除吗?', {
        btn: ['确定','取消'] //按钮
     }, function(){
        
		//执行删除操作
		  $.ajax({
			type:'post',
			url:"{:U('User/del')}",
			data:{id:id},
			dataType:'json',
			success:function(res){
			  layer.msg(res.msg, {icon: res.code});
			  res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
			}
		});
		
		 
		 
     });

}

//积分清零
function clear_point(id){
	layer.confirm('您确定要清零吗?', {
        btn: ['确定','取消'] //按钮
     }, function(){
        
		//执行操作
		  $.ajax({
			type:'post',
			url:"{:U('User/point_clear')}",
			data:{id:id},
			dataType:'json',
			success:function(res){
			  layer.msg(res.msg, {icon: res.code});
			  res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
			}
		});
		
		 
		 
     });

}

//全选
$("#checkall").click(function(){ 

	if(this.checked)
	  {   
        	  $("input[name='id[]']").each(function(){
	              this.checked = true;
			  });
	   }
	   else
	   {   
			  $("input[name='id[]']").each(function(){
	              this.checked = false;
			  });
 
	  }   

 
});
//设置全选复选框
$("input[name='id[]']").click(function(){
	allchk();
});
function allchk(){
 
	var chknum= $("input[name='id[]']").length;//选项总个数
	var chk = 0;
	$("input[name='id[]']").each(function () {  
        if($(this).prop("checked")==true){
			chk++;
		}
    });
	if(chknum==chk){
		//全选
		$("#checkall").prop("checked",true);
	}else{
		//不全选
		$("#checkall").prop("checked",false);
	}
}

 

//批量删除
function DelSelect(){
	var Checkbox=false;
	var chk_id_arr=[];
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
		chk_id_arr.push($(this).val());
		
	  }
	});

	if (Checkbox){
  
	  layer.confirm('您确认要删除选中的内容吗?', {
        btn: ['确定','取消'] //按钮
     }, function(){
        
		//执行删除操作
	 $.ajax({
		 type:'post',
		 url:"{:U('User/del')}",
		 data:{id:chk_id_arr},	
		 dataType:'json',
		 success:function(res){
			 console.log(res);
			 
			 layer.msg(res.msg, {icon: res.code});
		
			 res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
		   }
			
		});
  
     });
 	 
	}
	else{
	 
	  layer.alert('请选择您要删除的记录!', {
	  skin: 'layui-layer-molv', //样式类名
	  closeBtn: 0});
	   return false;
	}
}
 
 
</script>

 

</body>
</html>